require(["config"], function() {
	require(["jquery","swiper", "template", "load"], function($, Swiper,template) {
        function Index(){
            this.loadIndex();
        }
          
        $.extend(Index.prototype,{
            //加载渲染列表商品
            loadIndex(){
                $.getJSON("http://rap2api.taobao.org/app/mock/120970/api/index",(data)=>{
                    
                   const html = template("prod-temp",{ports:data.res_body.list})
                   
                   $("ul.grid_1").prepend(html);
                })
            }
        });
        new Index();

        var mySwiper = new Swiper('.swiper-container', {
            speed: 500,
            autoplay: {
                delay: 2000
            },
            loop: true, // 循环模式选项


            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
                clickable: true, // 鼠标点击跳转
            },
        })

        // 鼠标移动到图片停止 移开继续
        $('.swiper-slide').mouseenter(function () {
            mySwiper.autoplay.stop();
        });
        $('.swiper-slide').mouseleave(function () {
            mySwiper.autoplay.start();
        });

        //鼠标放在圆点上 展厅 移开继续 
        for (var i = 0; i < mySwiper.pagination.bullets.length; i++) {
            mySwiper.pagination.bullets[i].onmouseover = function () {
                this.click();
            };
        }

	});
});
